
#include"stdio.h"
#include"stdlib.h"
#include"phga.h"
//#include"hphiga.h"
#include"useful_math.h"
#include"useful_utils.h"
#include"unistd.h"
#include"fitness.h"


int minor_cccs(int** possible_building_blocks, int* blocks, int array_size, float* cccs, int number_of_bbs)
{
	if(cccs==NULL)
	{
		printf("ERROR: CCCS NULL!\n");
		return 0;
	}

	//choose the minimum ccc's building block set
	int i;
	
	int chosen_bb= number_of_bbs -1;
	float minimum=cccs[chosen_bb];
	//from top to leaf, excluding the top and the leaf that are not stored
	for(i=number_of_bbs-2; i>=0;i--)
	{
		if(minimum > cccs[i])
		{
			chosen_bb= i;
			minimum=cccs[chosen_bb];
			//printf("chosen bb %d,  %.2f,  %.2f\n",chosen_bb, cccs[chosen_bb], minimum);
		
		}
	
		//printf("chosen bb %.2f\n", cccs[i]);
	}

	chosen_bb+= 2;

	//printf("chosen bb %d,  %.2f,  %.2f\n",chosen_bb, cccs[chosen_bb], minimum);

	return (chosen_bb);


}

int main(int argc, char** argv)
{
/*
	

	int size=30;

	int *c= (int*)malloc(sizeof(int)*size);

	for(int i=0; i<size; ++i)
	{
		c[i]=0;
	}

	printArray( c, size);

	//float result= f3deceptiveOverlapping(c, 0, size);
	//float result= trap5_cyclic(c, 0, size);
	float result= f3deceptiveBipolar(c, 0, size);

	printf("results %.2f\n",result);

	return 0;
	*/


	phga* ga= new phga("parameters", argc, argv);


	float fitness;

	while(ga->evolve(-1, &fitness)==true)
	{


//		if(ga->generation==2)
//		{
//			pop=3000;	
//		}
		//break;
		if(ga->generation==30)
			break;
	
	//	sleep(1);
	}

	ga->printSimpleResult();
	
	//ga->printResult();

	delete ga;

	
	return 0;
}



